package leetcode;

public class SwapNodesinPairs {

	 public ListNode swapPairs(ListNode head) {
	  int i=0;
	  ListNode pre=head;
	  while(head!=null){
		  i++;
		  if(i%2==1){
			  ListNode next=head.next;
			  if(next!=null){
				  int temp=head.val;
				      head.val=next.val;
				      next.val=temp;
			  }
		  }
		  head=head.next;
	  }
	  return pre;
	 }
}
